<?php

namespace app\admin\controller;

use app\admin\model\Order as Orders;
use app\admin\model\OrderProduct as Order_Goods;
use think\Request;

class Order extends Base
{
    public function order_list()
    {

        $orders = Orders::with(['memberAddress'])->paginate(2);


        return view('order/order-list', [
            'orders' => $orders
        ]);
    }

    public function order_add()
    {
        return view('order/order-add');
    }

    public function order_detail($id)
    {
        $order = Orders::with(['memberAddress'])->where('id',$id)->find();

        $order_goods = Order_Goods::with(['Good'])->where('order_id',$id)->paginate(2);


        return view('order/order-view',[
            'order'=>$order,
            'order_goods'=>$order_goods,
        ]);

    }

    public function send_out(Request $request)
    {
        $data = $request->param();
        if (Orders::update($data)){

            $this->success('修改状态成功');
        }else{

            $this->error('修改状态失败');

        }

    }


}
